package com.qixiucoding.learn_liu;

import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Description TODO
 * @Author longhj
 * @Date 2021/11/21 星期日 14:50
 */
public class LearnOutputStream {
    @Test
    public void testOutputStream1() {
        try {
            // File file = new File("b.txt");
            FileOutputStream fileOutputStream = new FileOutputStream("c.txt", true);
            fileOutputStream.write(97);
            fileOutputStream.write(97);
            fileOutputStream.write(98);
            fileOutputStream.write(97);
            fileOutputStream.write(new String("大龙111").getBytes());
            fileOutputStream.close();
        } catch (
                IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testOutputStream2() {
        try {
            // File file = new File("b.txt");
            FileOutputStream fileOutputStream = new FileOutputStream("d.txt");
            byte[] bytes = {58, 66, 56, 77, 100,97,98,99,100,101};
            for (byte aByte : bytes) {

                fileOutputStream.write(aByte);
                fileOutputStream.write("\r\n".getBytes());
            }
            fileOutputStream.close();
        } catch (
                IOException e) {
            e.printStackTrace();
        }
    }
}
